<?php
/*
 Files :          commandFile.php, (require ConfFile.php)
 Name :           Derived class for manipulation with command.conf ("Conf-File ver. (0.11)")
 Version :        1.2
 Release :        30. 1. 2007
 Descript :       Derived class for manipulation with command.conf ("Conf-File ver. (0.11)")
 derived form ConfFile

 Functions:
 Derived form ConfFile class :
 public function GetData()
 public function Open($filename)
 public function Close()
 public function Load()
 public function AddItem($block,$parametr,$value)
 public function EditItem($block, $item, $index, $new_value)
 public function DeleteItem($block, $item, $index)
 public function AddBlock($block)
 public function DeleteBlock($block)
 public function RenameBlock($block, $newblock)

 New functions in class:
 public function FindFile($text)      -> returns information about command or false

 */

require_once("ConfFile.php");

class commandFile extends ConfFile
{

  public function __construct($filename="n/a")
  {
    if ($filename == "n/a") $filename='commands.php';
    parent::__construct($filename);
    $this->Load();
  }

  /**
   * Vrátí název souboru ve kterém je command zadaný jako parametr
   *
   * @param string $Command Název commandu
   * @return bool
   */
  public function GetCommandFile($Command)
  {
    reset($this->Data);
    do {
      if (trim(key($this->Data)) == trim($Command))
      {
        if (isset($this->Data[key($this->Data)]['file'])) {
          return ereg_replace('/',DIRECTORY_SEPARATOR,$this->Data[key($this->Data)]['file'][0]).'.php';
        }
        elseif (isset($this->Data[key($this->Data)]['alias']))
        {
          $Alias = trim($this->Data[key($this->Data)]['alias'][0]);
          do {
            if ($Alias == trim(key($this->Data))) {
              return ereg_replace('/',DIRECTORY_SEPARATOR,$this->Data[key($this->Data)]['file'][0]).'.php';
            }
          }while(Next($this->Data));
        }
      }
    } while(Next($this->Data));
    return false;
  }
}
?>